<?php
/**
 * 
 * Empty (空模块)
 *
 * @package      	szflame
 * @author          
 * @copyright     	
 * @license         
 * @version        	szflame企业网站管理系统 v2012.12.12 2011-03-01 198616.com $
 */
if(!defined("szflame")) exit("Access Denied");
class EmptyAction extends Action
{	
	public function _empty()
	{
		//空操作 空模块
		if(MODULE_NAME!='Urlrule'){  
			$Mod = F('Mod');			
			if(!$Mod[MODULE_NAME]){ 
				if($_GET['_URL_']){
					$urlArr = $_GET['_URL_'];
				}else{
					$urlArr = $_GET;
				} 
				$array_end_param = array_pop($urlArr);
				
				if(strstr($array_end_param,'detail')){
					//详细页
					$array = explode("_",$array_end_param);
					if($array[0]=='detail' && is_numeric($array[1])){
						$id = $array[1];
						$map['catdir']=array_pop($urlArr);
						if($urlArr){
							$map['parentdir'] = implode("/",$urlArr)."/";
						}
						$cat = M('Category')->where($map)->field('id,module')->order('id desc')->find();
						import('@.Action.Base');
						$bae=new BaseAction();
						$bae->show((int)$id,$cat['module']);
						//echo file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/index.php?m='.$cat['module'].'&a=show&&id='.$id);
						die();
					}
				}else{
					if(strstr($array_end_param,'index') ||strstr($array_end_param,'list_')){
						$array = explode("_",$array_end_param);
						if($array[0] =="list" && is_numeric($array[1])){
							$map['id'] = intval($array[1]);
						}
						if($array[0] =="list" || $array[0] =="index"){
							$array_end_param = array_pop($urlArr);
						}
					}					
					//列表页
					if($urlArr){
					$map['parentdir'] = implode("/",$urlArr)."/";
					}
					$map['catdir']=$array_end_param;
					$cat = M('Category')->where($map)->field('id,module')->order('id desc')->find();
					if($cat){ //var_dump($cat);
						import('@.Action.Base');
						$bae=new BaseAction();
						$bae->index((int)$cat['id'],$cat['module']);
						//echo file_get_contents('http://'.$_SERVER['HTTP_HOST'].'/index.php?m='.$cat['module'].'&id='.$cat['id']);
						die();
					}else{
						echo file_get_contents('http://'.$_SERVER['HTTP_HOST']);
						die();
					}
				}
				throw_exception('404');
			}else{
				import('@.Action.Base');
				$bae=new BaseAction(); 
				if(ACTION_NAME == 'index'){
					$cat = M("Category")->find($_GET['id']);
					$bae->index((int)$cat['id'],$cat['module']);
					exit();
				}elseif(ACTION_NAME == 'show'){
					$vo = M("Article")->find($_GET['id']);
					$id = $vo['id'];
					$cat = M("Category")->find($vo['catid']);
					$bae->show((int)$id,$cat['module']);
					exit();
				}else{
					throw_exception('404');
				}
				exit();
			}
		}
	}
}
?>